/*
 * Identifies the current (and target) platform, compiler, endianness etc
 * Also provides workarounds for compiler differences
 */

#ifndef OA_UTIL_PLATFORM_H
#define OA_UTIL_PLATFORM_H

	#define OA_PLATFORM_WIN32 1
	#define OA_PLATFORM_LINUX 2
	#define OA_PLATFORM_OSX 3

	#define OA_COMPILER_MSVC 1
	#define OA_COMPILER_GNUC 2

	#define OA_ENDIAN_LITTLE 1
	#define OA_ENDIAN_BIG 2

	#define OA_ARCH_32 1
	#define OA_ARCH_64 2

	/* Compiler detection */
	#if defined (_MSC_VER)
		#define OA_COMPILER OA_COMPILER_MSVC
		#define OA_COMPILER_VERSION __MSC_VER
	#elif defined (__GNUC__)
		#define OA_COMPILER OA_COMPILER_GNUC
		#define OA_COMPILER_VER (((__GNUC__) * 100) + __GNUC_MINOR__)
	#else
		#pragma warning "Unsupported compiler."
	#endif

	/* Platform detection */
	#if defined (__WIN32__) || defined (_WIN32)
		#define OA_PLATFORM OA_PLATFORM_WIN32
	#elif defined (__APPLE_CC__)
		#define OA_PLATFORM OA_PLATFORM_OSX
	#else
		#define OA_PLATFORM OA_PLATFORM_LINUX
	#endif

	/* Architecture detection */
	#if defined(__x86_64__)
		#define OA_ARCH OA_ARCH_64
	#else
		#define OA_ARCH OA_ARCH_32
	#endif

	/* Windows specific */

	#if OA_PLATFORM == OA_PLATFORM_WIN32
		#define WIN32_LEAN_AND_MEAN
		#define WIN32_EXTRA_LEAN
		//#include <windows.h>

		#ifdef min
			#undef min
		#endif

		#ifdef max
			#undef max
		#endif

		#if defined(BUILD_DLL)
			#define _OA_export __declspec(dllexport)
		#elif defined(CLIENT_BUILD)
			#define _OA_export __declspec(dllimport)
		#else
			#define _OA_export 
		#endif

		#ifdef _DEBUG
			#define OA_DEBUG_MODE 1
		#else
			#define OA_DEBUG_MODE 0
		#endif
	#endif
	/* TBA Linux specific */

	#if OA_PLATFORM == OA_PLATFORM_LINUX
		#define _OA_export 
	#endif

	/* TBA OSX specific */

	#if OA_PLATFORM == OA_PLATFORM_OSX
		#define _OA_export
	#endif
#endif
